<!--
 * @Description: 工程策划表汇总
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2022-03-15 16:20:22
 * @LastEditTime: 2022-07-18 13:55:07
 * @FilePath: \cscec-pms-admin\src\views\project\plannManagement\plannTableSummary\index.vue
-->
<template>
  <base-breadcrumb>
    <!-- 搜索 -->
    <searchData
      ref="search"
      :search-data="searchOption"
      @search="search"
      @reset="reset"
    />
    <!-- 搜索 -->
    <a-card>
      <!-- <title-name title="策划执行书汇总列表" /> -->
      <list-table
        ref="table"
        row-key="id"
        :columns="columns"
        :request="loadData"
        :alert="true"
        show-size-changer
        show-quick-jumper
      >
        <template
          slot="operation"
          slot-scope="text, record"
        >
          <MoreButton>
            <!-- 未确认 -->
            <a
              v-btnPermission="[{code:'seex_pm_053_loo_01',ident:'prma_seex'},{code:'buco_pm_053_loo_01',ident:'prma_buco'}]"
              @click="handleOperation('detail',record)"
            >查看</a>
            <a
              v-btnPermission="[{code:'seex_pm_053_exp_03',ident:'prma_seex'},{code:'buco_pm_053_exp_03',ident:'prma_buco'}]"
              :href="'/api/plan-producer-server/scheme/exportWord?access_token=' + token + '&id=' + record.id"
              target="_parent"
            >导出</a>
            <a
              v-if="record.status !== 1 && record.status !== 3"
              v-btnPermission="[{code:'seex_pm_053_edi_02',ident:'prma_seex'},{code:'buco_pm_053_edi_02',ident:'prma_buco'}]"
              @click="handleOperation('update',record)"
            >编辑</a>
            <a
              v-if="record.status !== 0"
              @click="$bus.$emit('showApprovalDetailsDialog', record.id)"
            >审批信息</a>
          </MoreButton>
        </template>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>
<script>
import { searchOption, columns } from './model.js'
import MoreButton from '@/components/MoreButton'
import { list } from '@/api/project/plannManagement/plannTableSummary'
import Vue from 'vue'
export default {
  name: 'plannTableSummary' + Date.now(),
  components: {
    MoreButton
  },
  data() {
    return {
      // 令牌
      token: Vue.getAcloudProvider().getAccessToken(),
      // 搜索选项
      searchOption,
      // 表头
      columns,
      // 查询参数
      searchData: {}
    }
  },
  methods: {
    /**
     * @description: 搜索
     * @param {Object} value 搜索数据
     * @return {Void}
     */
    search(value) {
      this.searchData = value || {}
      this.$refs.table.refresh(true)
    },
    /**
     * @description: 搜索重置
     * @param {void}
     * @return {void}
     */
    reset() {
      this.$refs.search.form.setFieldsValue({ projectName: this.projectInfo?.projectName })
    },
    /**
     * @description: 表格数据加载方法
     * @param {Object} parameter 分页信息
     * @return {Promise} 接口Promise
     */
    async loadData(parameter) {
      try {
        const params = Object.assign({}, { pageNum: parameter.pageNo, pageSize: parameter.pageSize }, { param: this.searchData })
        console.log(params)
        const res = await list.getPageSchemeBySearch(params)
        if (res.code === 200) {
          return Promise.resolve(res)
        } else {
          return Promise.reject()
        }
      } catch (error) {
        console.log(error)
        return Promise.reject()
      }
    },
    /**
     * @description: 操作
     * @param {string} pageType 操作类型
     * @param {object} record 行数据
     * @return {void}
     */
    handleOperation(pageType, record) {
      const { id } = record
      this.$router.push({
        path: '/project/plannManagement/plannTableSummaryView',
        query: {
          pageType,
          id
        }
      })
    }
  }
}
</script>
<style lang="scss">
</style>
